package com.kloooong.top.producer;

import com.dingteam.push.api.channel.OrgUserOutput;
import com.dingteam.push.api.message.OrgUserMessage;
import com.kloooong.top.channel.UserVipOutput;
import com.kloooong.top.message.UserVipMember;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Date;
import java.util.UUID;

@Component
@EnableBinding({UserVipOutput.class})
public class UserVipProducer {

    @Resource(name = UserVipOutput.OUTPUT)
    private MessageChannel messageChannel;

    public boolean sendVip(UserVipMember member, String headerId) {
        System.out.println("stream push alread...");
        MessageBuilder builder = MessageBuilder.withPayload(member)
                .setHeader("headerId", headerId)
                .setHeader("action", "user");
        return messageChannel.send(builder.build());
    }

}